package com.tedu.parkinglot.order.controller;

import com.tedu.parkinglot.base.response.JsonResult;
import com.tedu.parkinglot.order.pojo.dto.ChargeParam;
import com.tedu.parkinglot.order.pojo.dto.OrderSaveParam;
import com.tedu.parkinglot.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Collection;

@Slf4j
@RestController
@RequestMapping("/order")
@Api(tags = "订单管理")
public class OrderController {
    @Autowired
    private OrderService orderService;
    //新增订单
    @PostMapping("/add")
    @ApiOperation(value = "新增订单")
    public JsonResult addOrder(@Valid @RequestBody OrderSaveParam order) {
        orderService.saveOrder(order);
        return JsonResult.ok();
    }
    @PostMapping("/updateOrder")
    @ApiOperation(value = "更新订单")
    public JsonResult updateOrderAndPayment(@RequestBody ChargeParam chargeParam) {
        log.info("updateOrder:{}",chargeParam);
        orderService.updateOrderAndPayment(chargeParam);
        return JsonResult.ok();
    }
}
